﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

using TYAJZWeb.Data;

namespace TYAJZWeb.Models
{
    public class EquipmentModelListModel
    {

        public int Id { get; set; }

        [Display(Name = "型号")]
        public string Name { get; set; }

        [Display(Name = "年份")]
        public int LimitedYear { get; set; }

        public static explicit operator EquipmentModelListModel(EquipmentModel model)
        {
            return new EquipmentModelListModel()
            {
                Id = model.Id,
                LimitedYear = model.LimitedMonth / 12,
                Name = model.Name
            };
        }
    }

    public class EquipmentModelEditModel
    {
        public int Id { get; set; }

        [Display(Name = "型号")]
        public string Name { get; set; }

        [Display(Name = "年份")]
        public int LimitedYear { get; set; }

        public static explicit operator EquipmentModel(EquipmentModelEditModel model)
        {
            return new EquipmentModel()
            {
                Id = model.Id,
                LimitedMonth = model.LimitedYear * 12,
                Name = model.Name
            };
        }

        public static explicit operator EquipmentModelEditModel(EquipmentModel model)
        {
            return new EquipmentModelEditModel()
            {
                Id = model.Id,
                LimitedYear = model.LimitedMonth / 12,
                Name = model.Name
            };
        }
    }
}